package com.meihua.workflow;

import cn.hutool.core.date.DateTime;
import cn.hutool.cron.CronUtil;
import cn.hutool.cron.task.Task;
import cn.hutool.http.HttpUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.HashMap;

@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
public class WorkflowApplication {
    public static void remind() {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("msg_type","text");
        HashMap <String,Object> contentMap= new HashMap<>();
        contentMap.put("text", "SendMessageByIdea");
        hashMap.put("content",contentMap);
        System.out.println(hashMap);
        String body="{    \"msg_type\": \"text\",\"content\": { \"text\": \"下班提醒：现在是"+new DateTime()+"记得按时下班！"+"\"}}";
        HttpUtil.post("https://open.feishu.cn/open-apis/bot/v2/hook/07b677a9-2224-4357-87d8-29661b1cdade", body);
        HttpUtil.post("https://open.feishu.cn/open-apis/bot/v2/hook/d590e4f9-19f7-42b2-97b0-92f88a3681d4", body);
    }

    public static void main(String[] args) {
        SpringApplication.run(WorkflowApplication.class, args);
//        CronUtil.schedule("0 0 17 * * 1-5", (Task) WorkflowApplication::remind);
//        //支持秒级
//        CronUtil.setMatchSecond(true);
//        //开启定时任务
//        CronUtil.start(true);
    }

}
